package com.module.my.adapter.holder

import android.graphics.Paint
import android.view.ViewGroup
import com.module.base.base.adapter.BaseViewHolder
import com.module.app.utils.GlideUtils
import com.module.my.R
import com.module.my.bean.MyBean
import com.module.my.databinding.MyItemMyBinding

class MyHolder(parent: ViewGroup) : BaseViewHolder<MyBean, MyItemMyBinding>(parent) {
    override fun convert(bean: MyBean, position: Int) {
        mDatabind.bean = bean
        if (!bean.right.isNullOrEmpty() && bean.right?.startsWith("已过期") == true) {
            //过期画中线
            mDatabind.tvRight.paint.flags = Paint.STRIKE_THRU_TEXT_FLAG //中划线
        } else {
            mDatabind.tvRight.paint.flags = 0 // 取消设置的的划线
        }
        mDatabind.tvRight.setTextColor(context.resources.getColor(if (bean.rightColorRes == 0) R.color.bg_gray_65 else bean.rightColorRes))
        if (bean.url.isNullOrEmpty()) {
            mDatabind.ivIcon.setImageResource(bean.idRes)
        } else {
            com.module.app.utils.GlideUtils.load(mDatabind.ivIcon.context, mDatabind.ivIcon, bean.url)
        }
    }
}